# -*- coding:UTF-8 -*-


from django.db import models
from django.contrib.auth.models import AbstractUser
from department.models import Departments
from work.models import Task


class Users(AbstractUser):
    mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    # department_id = models.IntegerField(verbose_name='所属部门id', default=0)
    department = models.ForeignKey(Departments, on_delete=models.CASCADE, db_constraint=False, default='1')
    name = models.CharField(max_length=20, verbose_name="姓名", default=None)
    is_manager = models.BooleanField(verbose_name="是否为管理员", default=False)
    is_staff = models.BooleanField(verbose_name="是否为管理员", default=True)
    position = models.IntegerField(verbose_name='工作流中的职位', default=None, null=True)
    task = models.ManyToManyField(Task, related_name='userOfTask')
    job = models.CharField(max_length=10, verbose_name='岗位', null=True, default=None)
    is_company = models.IntegerField(default=1, verbose_name='是否是公司账户')
    area = models.CharField(max_length=30, null=True, default=None, verbose_name='子公司地址')
    contact = models.CharField(max_length=5, null=True, default=None, verbose_name='子公司联系人')

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name
